#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdlib.h>

int main()
{
    pid_t pid = fork();
    if(pid < 0)
    {
        perror("fork!");
        return 1;
    }
    if(pid == 0)//子进程
    {
        printf("i am child process,pid:%d\n",getpid());
        sleep(5);
        exit(666);
    }else{//父进程
        int status = 0;
        pid_t ret = waitpid(pid,&status,0);

        if(WIFEXITED(status))
        {
            printf("child process exited with status:%d\n",ret);
        }
    }

    return 0;
}
